﻿using System;
using System.Collections.Generic;
using System.Data;
using PPI.Client.Entities;
using PPI.Entities;

namespace PPI.Client.Logic
{
    public class LReport
    {
        public static DataSet getReportDataset(ReportsEnum typeReport, int projectId)
        {
            DataSet ds = null;

            switch (typeReport)
            {
                case ReportsEnum.PolesByAge:
                    ds = WebConsumer.WReport.GetReportPolesByAge(8);
                    break;
                case ReportsEnum.VisitsByPole:
                    ds = WebConsumer.WReport.GetReportVisitsByTop(8);
                    break;
                case ReportsEnum.VisitByWeekContact:
                    ds = WebConsumer.WReport.GetReportVisitsByWeekContact();
                    break;
                case ReportsEnum.InspectionByWeekContact:
                    ds = WebConsumer.WReport.GetReportInspectionsByWeekContact();
                    break;
                case ReportsEnum.InspectionTypeByWeekInspector:
                    //ds = WebConsumer.WReport.GetReportInspectionsTypeByWeekInspector();
                    ds = WebConsumer.WReport.GetReportInspectionsTypeByWeekInspector(projectId);
                    break;
                case ReportsEnum.DistributionInspectionTypeByWeekInspector:
                    ds = WebConsumer.WReport.GetReportDistributionInspectionsTypeByWeekInspector();
                    break;
                case ReportsEnum.ProjectSummary:
                    //ds = WebConsumer.WReport.GetReportProjectSummary();
                    ds = WebConsumer.WReport.GetReportProjectSummary(projectId);
                    break;
                case ReportsEnum.DistributionInspectionProjectSummary:
                    ds = WebConsumer.WReport.GetReportDistributionInspectionProjectSummary();
                    break;
                case ReportsEnum.LineProblemsByResultAndNote:
                    ds = WebConsumer.WReport.GetReportLineProblemsByResultAndNote();
                    break;
                case ReportsEnum.IssueByResult:
                    ds = WebConsumer.WReport.GetReportIssueByResult();
                    break;
            }
            if (ds != null)
                return ds;
            else
                throw new Exception("Please select one Report");
        }

        public static List<EReport> GetAllReports()
        {
            List<EReport> listReports = new List<EReport>();
            EReport report = new EReport(ReportsEnum.VisitsByPole, "PPIReporting.rptByPoleTop.rdlc", "Transmission Poles Visits by Pole Top", "ReportDataset_up_Report_VisitsbyTop");
            listReports.Add(report);
            report = new EReport(ReportsEnum.PolesByAge, "PPIReporting.rptPolesByAge.rdlc", "Transmission Poles Visits by Pole Age", "ReportDataset_up_Report_PolesByAge");
            listReports.Add(report);
            report = new EReport(ReportsEnum.VisitByWeekContact, "PPIReporting.rptVisitsByContact.rdlc", "Transmission Visits by Contact", "DataSet2_rpt_VisitsByWeekAndContact");
            listReports.Add(report);
            report = new EReport(ReportsEnum.VisitByWeekContact, "PPIReporting.rptVisitsByWeek.rdlc", "Transmission Visits by Week", "DataSet2_rpt_VisitsByWeekAndContact");
            listReports.Add(report);
            report = new EReport(ReportsEnum.InspectionByWeekContact, "PPIReporting.rptInspectionsByContact.rdlc", "Inspection Visits by Contact", "DataSet2_rpt_VisitsByWeekAndContact");
            listReports.Add(report);
            report = new EReport(ReportsEnum.InspectionTypeByWeekInspector, "PPIReporting.rptInspectionTypeByWeekAndInspector.rdlc", "Inspection Type by Week and Inspector", "SQL2005_390264_betaDataSet_up_Report_InspectionTypesByWeekAndInspector");
            report.HasParameters = true;
            listReports.Add(report);
            report = new EReport(ReportsEnum.ProjectSummary, "PPIReporting.rptProjectSummary.rdlc", "Project Summary", "SQL2005_390264_devpoleposiDataSet_up_Report_ProjectSummary", true);
            report.OtherDatasources.Add("SQL2005_390264_devpoleposiDataSet_up_Report_ProjectSummary_Isssue");
            report.OtherDatasources.Add("SQL2005_390264_devpoleposiDataSet_up_Report_ProjectSummary_Budget");
            report.HasParameters = true;
            listReports.Add(report);
            report = new EReport(ReportsEnum.LineProblemsByResultAndNote, "PPIReporting.rptSumarizeLineProblems.rdlc", "Issues by Type", "SQL2005_390264_betaDataSet_up_Report_LineProblemsByResultAndNote");
            listReports.Add(report);
            report = new EReport(ReportsEnum.IssueByResult, "PPIReporting.rptIssueByResult.rdlc", "Issues by Result", "SQL2005_390264_betaDataSet1_DataTable1");
            listReports.Add(report);
            report = new EReport(ReportsEnum.AssetDescription, "PPIReporting.rptByAsset.rdlc", "Asset Summary", "SQL2005_390264_betaDataSet2_up_Report_InformationAsset", true);
            report.OtherDatasources.Add("SQL2005_390264_betaDataSet2_up_Report_InformationAsset_Gps");
            report.OtherDatasources.Add("SQL2005_390264_betaDataSet2_up_Report_InformationAsset_Inspections");
            report.HasParameters = true;
            listReports.Add(report);
            report = new EReport(ReportsEnum.DistributionInspectionTypeByWeekInspector, "PPIReporting.rptDistributionInspectionTypeByWeekAndInspector.rdlc", "Distribution Inspection Type by Week and Inspector", "SQL2005_390264_betaDataSet_up_Report_DistributionInspectionTypesByWeekAndInspector");
            listReports.Add(report);

            report = new EReport(ReportsEnum.DistributionInspectionProjectSummary, "PPIReporting.rptDistributionInspectionProjectSummary.rdlc", "Distribution Inspection Project Summary", "SQL2005_390264_betaDataSet_up_Report_DistributionInspectionProjectSummary", true);
            report.OtherDatasources.Add("SQL2005_390264_betaDataSet_up_Report_DistributionInspection_ProjectSummary_Isssue");
            report.OtherDatasources.Add("SQL2005_390264_betaDataSet_up_Report_DistributionInspection_ProjectSummary_Budget");
            listReports.Add(report);

            return listReports;
        }

        public static DataSet getReportDatasetWithParameters(ReportsEnum typeReport, Dictionary<string,object> parameters)
        {
            DataSet ds = null;

            switch (typeReport)
            {
                case ReportsEnum.PolesByAge:
                    ds = WebConsumer.WReport.GetReportPolesByAge(8);
                    break;
                case ReportsEnum.VisitsByPole:
                    ds = WebConsumer.WReport.GetReportVisitsByTop(8);
                    break;
                case ReportsEnum.VisitByWeekContact:
                    ds = WebConsumer.WReport.GetReportVisitsByWeekContact();
                    break;
                case ReportsEnum.InspectionByWeekContact:
                    ds = WebConsumer.WReport.GetReportInspectionsByWeekContact();
                    break;
                case ReportsEnum.InspectionTypeByWeekInspector:
                    //ds = WebConsumer.WReport.GetReportInspectionsTypeByWeekInspector();
                    Int32 projectId = (Int32)parameters["ProjectId"];
                    ds = WebConsumer.WReport.GetReportInspectionsTypeByWeekInspector(projectId);
                    break;
                case ReportsEnum.DistributionInspectionTypeByWeekInspector:
                    ds = WebConsumer.WReport.GetReportDistributionInspectionsTypeByWeekInspector();
                    break;
                case ReportsEnum.ProjectSummary:
                    projectId = (Int32)parameters["ProjectId"];
                    //ds = WebConsumer.WReport.GetReportProjectSummary();
                    ds = WebConsumer.WReport.GetReportProjectSummary(projectId);
                    break;
                case ReportsEnum.DistributionInspectionProjectSummary:
                    ds = WebConsumer.WReport.GetReportDistributionInspectionProjectSummary();
                    break;
                case ReportsEnum.LineProblemsByResultAndNote:
                    ds = WebConsumer.WReport.GetReportLineProblemsByResultAndNote();
                    break;
                case ReportsEnum.IssueByResult:
                    ds = WebConsumer.WReport.GetReportIssueByResult();
                    break;
                case ReportsEnum.AssetDescription:
                    Int32 assetId = (Int32) parameters["AssetId"];
                    ds = WebConsumer.WReport.GetReportAssetDescription(assetId);
                    break;
            }
            if (ds != null)
                return ds;
            else
                throw new Exception("Please select one Report");
        }
    }
}
